package com.ninghushangbao.ninghu.controller;

import com.ninghushangbao.ninghu.controller.vo.ResultEntity;
import com.ninghushangbao.ninghu.entity.Join;
import com.ninghushangbao.ninghu.entity.Product;
import com.ninghushangbao.ninghu.service.JoinService;
import com.ninghushangbao.ninghu.utils.BaseResult.ResultUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/contact")
@CrossOrigin()
public class ContactController {

    @Autowired
    JoinService joinService;

    @GetMapping()
    public ResultEntity getContactUs(){
        return null;
    }

    /*
    *新增招聘
    * */
    @PostMapping("/job_add")
    public ResultEntity addProduct(@RequestBody Join join){
        System.out.println(join);
        joinService.addJoin(join);
        return ResultUtil.success();
    }

    @GetMapping("/sel_all")
    public ResultEntity selectJoin(){
        List<Join> joins = joinService.selectJoin();
        for (Join join:joins) {
            System.out.println(join);
        }
        return ResultUtil.success(joins);
    }

    @DeleteMapping("/job_del")
    public ResultEntity deleteProduct(@RequestBody List<Integer> list){
        joinService.deleteJoinById(list);
        return ResultUtil.success();
    }

    @PutMapping("/job_mod")
    public ResultEntity updateProduct(@RequestBody Join join){
        System.out.println(join);
        joinService.updateJoin(join);
        return ResultUtil.success();
    }

}
